<?php defined('BASEPATH') OR exit('No direct script access allowed');

/**
 * Description: 删除一个地址
 *
 * @author      Eden
 * @datetime    2016/12/2 19:34
 * @copyright   Beijing CmsTop Technology Co.,Ltd.
 */


class Delete_Model extends API_Model
{

    // 参数
    private $params = array();

    /**
     * 初始化
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * 主程序
     * @param array $params
     */
    public function run(Array $params)
    {
        $send['state'] = false;
        do {

            if (empty($params['addressId'])) {
                $send['error'] = '参数错误';
                break;
            }

            $this->db->where('id', $params['addressId']);
            $res = $this->db->update('user_address', array('status' => -1));
            if ($res) {
                $send['state'] = true;
                $send['data'] = array(
                    'msg' => '删除成功'
                );
            } else {
                $send['error'] = '删除失败';
            }
        } while(false);
        $this->output->send($send);
    }

}

